package cn.tedu.configuretion;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;

/**
 * 验证框架配置
 * 目标 提示快速失败的思想
 */
@Slf4j
@Configuration
public class ValidationConfiguration {

    @Bean
    public javax.validation.Validator validator(){
        return Validation.byProvider(HibernateValidator.class)
                .configure()
                .failFast(true) //快速失败,一个检查不通过,就返回,不会继续检查
                .buildValidatorFactory()
                .getValidator();
    }




}
